<template>
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center subTalk_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub subTalk_fd0_0'>
					<view class='flex flex-wrap align-center subTalk_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  subTalk_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='subTalk_fd0_0_c1_c0'>{{$t('主题讨论')}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-end subTalk_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout subTalk_flex_1">
				<view class='flex flex-direction flex-wrap align-stretch subTalk_fd1_0'>
					<view class='flex flex-wrap align-stretch flex-sub'>
						<image class='subTalk_fd1_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"1615.png"'></image>
						<text class="flex-sub">{{name}}</text>
					</view>
				</view>
				<view class='flex flex-direction flex-wrap align-stretch subTalk_fd1_0'>
					<view class='flex flex-wrap align-stretch flex-sub subTalk_fd1_1_c0'>
						<text class='subTalk_fd1_1_c0_c0'>{{$t('回答：')}}</text>
					</view>
					<view class='flex flex-wrap subTalk_fd1_1_c1'>
						<benben-textarea class='flex subTalk_input_fd1_1_c1' :placeholder="$t('请输入')"
							:adjust-position='true' :maxlength="240" placeholder-style="color:#999;font-size:28rpx"
							v-model="talk" />

					</view>
				</view>
			</view>

			<!---flex布局flex布局结束-->
			<view class="flex flex-wrap align-center justify-center benben-position-layout flex subTalk_flex_2">
				<button class='subTalk_fd2_0' @tap.stop="getlf6f52a0f82cf0Func()">{{$t('提交回答')}}</button>

			</view>
			<view :style="{height: '88rpx'}"></view>

			<benben-popup v-model="submitShow" :mask="true" :mask-close-able="true" mode='center' :z-index='999999'>
				<!---flex布局flex布局开始-->
				<view class="popup-puter">
					<view class="top">提示</view>
					<view class="text">老师已结束主题讨论，是否确认提交</view>
					<view class="btns">
						<view class='btns_cancel' @tap.stop="submitShow=false">取消</view>
						<view class='btns_submit' @tap.stop="outLoginFunc">确定</view>
					</view>
				</view>
			</benben-popup>


		</view>
	</page-body>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"talk": "",
				"aid": "",
				name: "",
				submitShow: false,
				teachin: "",
				messid:'',//消息通知id
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			let {
				aid,
				name,
				teachin
			} = options
			if (aid !== undefined) this.aid = aid
			if (name !== undefined) this.name = name
			if (teachin !== undefined) this.teachin = teachin
			this.messid=options.messid
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 公告 已读
			async getred(){
				let datalist = await this.$api.get(global.apiUrls.post68413be3159e9, {
					aid: this.messid,
					
				});
							
				// if (datalist.data.code != 1) {
				// 	this.$message.info(datalist.data.msg);
				// 	return
				// }
			},
			async outLoginFunc() {
				let data66f52a0f82cf0 = await this.$api.post(global.apiUrls.post66f52a0f82cf0, {
					answer: this.talk,
					topicdiscussion_id: this.aid
				});
					this.getred()
				if (data66f52a0f82cf0.data.code != 1) {
					this.$message.info(data66f52a0f82cf0.data.msg);
					return
				}


				uni.navigateBack()
			},
			//APP接口-提交主题讨论答案
			async getlf6f52a0f82cf0Func() {
				if (!validate(this.talk, 'require')) {
					this.$message.info(global.i18n.t('提交内容不能为空'));
					return false;
				}

				//重新获取列表接口获取当前主题状态
				let datadataList = await this.$api.get(global.apiUrls.post66f526b296436, {
					teaching_id: this.teachin
				});

				if (datadataList.data.code != 1) {
					this.$message.info(datadataList.data.msg);
					return
				}
				const arr = datadataList.data.data
				const obj = arr.find(item => item.aid == this.aid)
				console.log('ccccccccccccccccc', arr, this.aid, obj);

				//已结束
				if (obj.topic_status == 2) {
					this.submitShow = true
				} else if (obj.topic_status == 0) {
					//未开始
					this.$message.info('讨论未开始');
				} else if (obj.topic_status == 1) {
					//开始
					this.outLoginFunc()
				}
			}
		}
	};
</script>
<style lang="scss" scoped>
	.popup-puter {
		width: 620rpx;
		height: 400rpx;
		background: #FFFFFF;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		padding: 40rpx 32px 0;

		.btns {
			display: flex;
			justify-content: space-between;

			.btns_cancel {
				width: 230rpx;
				height: 88rpx;
				background: #F8F8FA;
				border-radius: 50rpx 50rpx 50rpx 50rpx;
				line-height: 88rpx;
				text-align: center;
				font-size: 32rpx;
				color: #666666
			}

			.btns_submit {
				width: 230rpx;
				height: 88rpx;
				background: #F8F8FA;
				border-radius: 50rpx 50rpx 50rpx 50rpx;
				line-height: 88rpx;
				text-align: center;
				font-size: 32rpx;
				background: #145EFD;
				color: #FFFFFF
			}

		}

		.top {
			font-weight: 600;
			font-size: 36rpx;
			color: #333333;
			line-height: 32rpx;
			text-align: center;
			margin: 36rpx auto 0;
		}

		.text {
			font-weight: 400;
			font-size: 32rpx;
			color: #666666;
			line-height: 52rpx;
			text-align: center;
			margin: 36rpx auto;
		}
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.subTalk_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.subTalk_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 700;
		color: #333333;
		line-height: 50rpx;
	}

	.subTalk_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.subTalk_fd0_0_c0 {
		width: 120rpx;
	}

	.subTalk_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.subTalk_flex_1 {
		padding: 24rpx;
	}

	.subTalk_input_fd1_1_c1 {
		width: 100%;
		min-height: 260rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333;
		white-space: pre-wrap;
	}

	.subTalk_fd1_1_c1 {
		background: #f3f6f8;
		width: 650rpx;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		padding: 10rpx 10rpx 0rpx 16rpx;
		margin: 0rpx 0rpx 0rpx 0rpx;
		min-height: 260rpx;
	}

	.subTalk_fd1_1_c0_c0 {
		font-weight: 500;
		color: #333;
		font-size: 28rpx;
	}

	.subTalk_fd1_1_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.subTalk_fd1_0_c0_c0 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.subTalk_fd1_0 {
		background: var(--benbenbgColor1);
		margin: 0rpx 0rpx 24rpx 0rpx;
		padding: 32rpx 24rpx 32rpx 24rpx;
		background-size: 100% auto;
		border-radius: 24rpx;
	}

	.subTalk_flex_2 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(64rpx + var(--window-bottom));
		left: 0rpx;
	}

	.subTalk_fd2_0 {
		background: rgba(19, 77, 223, 1);
		border-radius: 12rpx;
		width: 622rpx;
		line-height: 88rpx;
		font-size: 32rpx;
		color: #fff;
	}
</style>